package com.dgshanger.sanhxiaofeisc.mvp.presenter

import com.dgshanger.sanhxiaofeisc.entity.PurseEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.PurseContract
import com.dgshanger.sanhxiaofeisc.mvp.model.PurseModel
import com.xx.baseuilibrary.mvp.BaseRxMvpPresenter
import com.xx.baseutilslibrary.network.rx.RxHttpObserver

/**
 * PursePresenter
 * 沉迷学习不能自拔
 * Describe：
 * Created by 雷小星🍀 on 2018/4/28 15:32.
 */

class PursePresenter : BaseRxMvpPresenter<PurseContract.Model, PurseContract.View>(), PurseContract.Presenter {

    override fun myWallet() {
        getModel().myWallet(object : RxHttpObserver<PurseEntity>() {

            override fun onCompleted(msg: String?, entity: PurseEntity?) {
                getView()?.setData(entity)
            }

            override fun onError(error: String?) {
                getView()?.showToast(error)
            }

            override fun onLoadingStart() {
                attachObserver(this)
                getView()?.setRefresh(true)
            }

            override fun onLoadingFinish() {
                getView()?.showContent()
                getView()?.setRefresh(false)
            }

        })
    }

    override fun createModel(): PurseContract.Model = PurseModel()
}
